<?php

class WelcomeController extends BaseController {

   
    /**
     * User Model
     * @var User
     */
    protected $user;

    /**
     * Inject the models.
     * @param User $user
     */
    public function __construct(User $user)
    {
        parent::__construct();

        $this->user = $user;
    }
    
	/**
	 * Returns all the blog posts.
	 *
	 * @return View
	 */
	public function getIndex()
	{

		// Show the page
        $eventos = Evento::all();
        $calendarEvent = array();
        foreach ($eventos as $evento){
            $fecha = new DateTime($evento->fecha_inicio);
            $fechaFin = new DateTime($evento->fecha_fin);
            do {
                $calendarEvent[$fecha->format('Y-m-d')] = array(
                        "badgeClass" => "badge-warning",
                        "url" => URL::to('eventos/' . $evento->id . '/details'),
                    );

                $fecha->add(new DateInterval('P1D'));

            }while($fecha <= $fechaFin);


        }
        JavaScript::put([
            'calendarEvent' => $calendarEvent,

        ]);
		return View::make('site/welcome');
	}

	
}
